const btn = document.querySelector('#btn');
const electron = require('electron');

console.log("electron", electron); // 输出在chromium的控制台里

const BroswerWindow = require('electron').remote.BrowserWindow;

window.onload = function () {
    btn.onclick = () => {
        newWin = new BroswerWindow({
            width: 800,
            height: 800,
        });
        newWin.loadFile('yellow.html');
        newWin.on('closed', () => {
            newWin = null;
        });
    };
};

const {remote} = electron;
var rightMenuTemplate = [
    {label: '复制', accelerator: 'ctrl+c'},
    {label: '粘贴', accelerator: 'ctrl+v'}
];

var m = remote.Menu.buildFromTemplate(rightMenuTemplate);

window.addEventListener('contextmenu', function (e) {
    e.preventDefault();
    m.popup({
        window: remote.getCurrentWindow(),
    });
});

